package com.zzq.my.jetpacks.jectpackapp.ui.act

import by.kirich1409.viewbindingdelegate.viewBinding
import com.aisier.architecture.base.BaseActivity
import com.google.android.flexbox.*
import com.zzq.my.jetpacks.jectpackapp.R
import com.zzq.my.jetpacks.jectpackapp.adapter.RvAdapter2
import com.zzq.my.jetpacks.jectpackapp.bean.ItemInfo
import com.zzq.my.jetpacks.jectpackapp.databinding.ActivityFlexboxlayoutBinding

/**
 * 描述：FlexboxLayout 弹性布局
 * 在android中我们经常所见的标签、流式布局等都可以用FlexboxLayout来实现
 * 作者：zhuangzeqin
 * 时间: 2022/1/19-14:05
 * 邮箱：zzq@eeepay.cn
 * 备注:
 */
class FlexboxLayoutAct :BaseActivity(R.layout.activity_flexboxlayout){
    private val binding by viewBinding(ActivityFlexboxlayoutBinding::bind)
    private lateinit var rvAdapter: RvAdapter2
    /**
     * 初始化数据
     */
    override fun initData() {
        rvAdapter = RvAdapter2()
        val mutableListOf = mutableListOf<ItemInfo>()
        val listOf = listOf("item01", "item02", "item03","item04","item05","item06","item07","item08","item09","item10","item11","item12","item13")
        listOf.forEach {
            mutableListOf.add(ItemInfo(it))
        }

        rvAdapter.setList(mutableListOf)
        binding.rvList.adapter = rvAdapter



    }



    /**
     * 初始化操作
     */
    override fun initView() {
        //FlexboxlayoutManager是支持View回收的，而FlexboxLayout是不支持View回收的，FlexboxLayout只适用于少量Item的场景，这也是为什么会出现FlexboxLayoutManager的原因吧.

        val flexboxLayoutManager = FlexboxLayoutManager(mContext)
        //设置主轴排列方式
        flexboxLayoutManager.flexDirection = FlexDirection.ROW
        flexboxLayoutManager.justifyContent = JustifyContent.FLEX_START
        //设置是否换行
        flexboxLayoutManager.flexWrap = FlexWrap.WRAP
        flexboxLayoutManager.alignItems = AlignItems.FLEX_START

        binding.rvList.layoutManager = flexboxLayoutManager


    }

    /**
     * 初始化点击事件操作
     */
    override fun eventOnClick() {

    }
}